package com.project.light.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class TokenEncrypt {

    public static String sha1(String input) throws Exception {
        StringBuilder sb = new StringBuilder();
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-1");
            byte[] messageDigest = md.digest(input.getBytes());

            for (byte b : messageDigest) {
                sb.append(String.format("%02x", b));
            }
        } catch (NoSuchAlgorithmException e) {
            throw new Exception("Exception thrown for incorrect algorithm: " + e);
        }
        return sb.toString();
    }
}
